package com.ujiuye.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * ClassName: ToJsonUtils <br/>
 * Description: <br/>
 * date: 2021/9/16 19:48<br/>
 *
 * @author 荒<br />
 * @since JDK 1.8
 */
public class ToJsonUtils {

    /**
     * 将一个对象装换为json
     * @param obj
     * @return
     */
    public static String toJson(Object obj) {
        ObjectMapper om = new ObjectMapper();
        try {
            return om.writeValueAsString(obj);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return null;
    }
}
